<?php

use think\migration\Migrator;
use think\migration\db\Column;

class PostComment extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('post_comment',['comment'=>'博客文章评论区','engine' => 'MyISAM'])
            ->addColumn('post_id','integer',['comment'=>'文章id'])
            ->addColumn('created','integer',['comment'=>"创建时间",'signed'=>false])
            ->addColumn('updated','integer',['comment'=>"修改时间",'signed'=>false])
            ->addColumn('parent_id','integer',['comment'=>'父评论id','signed'=>false])
            ->addColumn('username','string',['comment'=>'用户名称','limit'=>50])
            ->addColumn('email','string',['comment'=>'用户邮箱','limit'=>80])
            ->addColumn('content','string',['comment'=>'评论内容'])
            ->addColumn('ip','integer',['comment'=>'评论ip地址'])
            ->addColumn('agent','string',['comment'=>'浏览器'])
            ->create();
    }
}
